import java.sql.*;

public class Jdbc03 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        String url = "jdbc:mysql://localhost:3306/jdbc?useUnicode=true&characterEncoding=UTF-8&useSSL=true";
        String username = "root";
        String password = "root";
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection(url, username, password);
        //要先设置sql语句,再获取PreparedStatement对象
        String sql = "insert into user values(?,?,?,?,?);";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        //设置每个?的参数
        preparedStatement.setInt(1,1);
        preparedStatement.setString(2,"骏扬");
        preparedStatement.setString(3,"123456");
        preparedStatement.setString(4,"errr@qq.com");
        preparedStatement.setString(5,"2021-12-2");

        int i = preparedStatement.executeUpdate();

        preparedStatement.close();
        connection.close();

    }
}
